<?php





 function tree($data,$pid = 0,$count = 0) {
     foreach ($data as $key => $value){
            if($value['pid']==$pid){
                $value['count'] = $count;
                $list[]=$value;

                tree($data,$value['id'],$count+1);
            } 
        }
        return $list ;
    }
    
 function list_level($arr,$pid=0,$level=0){  
        //定义一个静态数组  
        $data = array();  
        foreach($arr as $k => $v){  
            if($v['pid'] == $pid){  
                $v['level'] = $level;  
                $data[] = $v;  
                list_level($arr,$v['id'],$level+1);  
            }  
        }  
        return $data;  
    }  
